// 导入需要的config和request
import confing from '../config/config.js';
import request from '../util/request.js';
// 申明请求对象
const processRequest = {
    // dict请求的基本url
    BASE_URL :  confing.PRO_URL + "/process",
    // 请求的API
    list(page = 1,limit = 10,proProcess,callback){
        // url
        let url = this.BASE_URL + "/list?page=" + page + "&limit=" + limit;
        if(proProcess){
            if(proProcess.processCode){
                url += "&processCode=" +proProcess.processCode;
            }
            if(proProcess.processName){
                url += "&processName=" +proProcess.processName;
            }
            if(proProcess.enableFlag){
                url += "&enableFlag=" +proProcess.enableFlag;
            }
        }
        // 发送请求
        request.get(url,callback);
    },
    //全部分页请求
    get(page = 1,limit = 10,callback){
        // url
        let url = this.BASE_URL + "/get?page=" + page + "&limit=" + limit;
        // 发送请求
        request.get(url,callback);
    },
    //自动生成编号
    genProcessCode(callback){
        console.log(1111111);
        let url=this.BASE_URL+'/genProcessCode';
        request.get(url,callback);
    },
    //新增工单
    save(proProcess,callback){
       let url=this.BASE_URL+'/save';
       request.post(url,proProcess,callback);
    },
    deleteProcess(processCode,callback){
        request.delete(this.BASE_URL+"/deleteProcess?processCode="+processCode,callback);
    },
    updateProcess(process,callback){
        console.log("ahsgg-----------"+ process.processName);
        let url=this.BASE_URL+'/update';
        console.log(url);
        request.post(url,process,callback);   
    },
    selectall(callback){
        let url=this.BASE_URL+'/selectall';
        request.get(url,callback);
    }
}

// 将dictRequest暴漏出去
export default processRequest;